export default {
  install: (app, options) => {
    if (!options || !options.router) {
      console.error('Vue Router instance is required for navigation plugin.')
      return
    }

    const router = options.router

    const ToPath = (path, query = {}, options = {}) => {
      // 执行路由跳转
      router.push({ path, query, options })
    }

    // 将 $ToPath 添加到全局属性
    app.config.globalProperties.$ToPath = ToPath

    // 提供给 inject 使用
    app.provide('toPath', ToPath)
  }
}
